<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多个异步任务顺序执行</title>
</head>
<body>
    <script type="text/javascript">
        function task1000 (input) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(input+1000)
                }, 1000)
            })
        }
        function task2000 (input) {
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve(input+2000)
                }, 1000)
            })
        }
        const p = new Promise((resolve, reject) => {
            resolve(1)
        })
        p.then(task1000)
        .then(task2000)
        .then(task1000)
        .then(task2000)
        .then( result => {
            console.log(result)
        })
        
        
       
    </script>
</body>
</html>